﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>流程评论</title>
</head>
<body onkeypress="Esc()">
    <script language="JavaScript" src="../../Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="css/demo.js" type="text/javascript"></script>
    <base target="_self" />
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link href="css/demo.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }
        var idx = 0;
        //页面启动函数.
        $(function () {
            $("#Msg").html("<img src=../../../Img/loading.gif />&nbsp;正在加载,请稍后......");
            InitPage();
            Count();
            $("#Msg").html("");
        });

        var fk_flow = GetQueryString("FK_Flow");
        var workid = GetQueryString("WorkID");
        var fid = GetQueryString("FID");

        //初始化数据.
        function InitPage() {
            $("#Table1  tr:not(:first)").html("");


            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("FlowBBSList");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            if (data == "[]") {
                return;
            }
            //转化成json.
            data = JSON.parse(data);
            //增加处理.
            for (var i = 0; i < data.length; i++) {
                //增加行.
                AddRow(data[i]);
            }
        }
        //删除.
        function Delete(mypk) {
            var name;
            if (window.confirm('您确定要删除吗？') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            handler.AddPara("MyPK", mypk);
            var data = handler.DoMethodReturnString("FlowBBS_Delete");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            // alert(data);

            $("#Table1  tr[id='" + mypk + "']").remove();
            Count();
        }
        var wait = 0;
        function time(o) {
            if (wait == 0) {
                o.removeAttribute("disabled");
                o.value = "提交评论";
                wait = 10;
            } else {
                o.setAttribute("disabled", true);
                o.value = "操作过于频繁，请" + wait + "秒后在提交";
                wait--;
                setTimeout(function () {
                    time(o)
                },
            1000)
            }
        }
        //统计评论条数
        function Count() {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("FlowBBS_Count");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            document.getElementById("TB_count").innerText = data;
        }
        function Check(empName, fk_flow) {

            $("#Table1  tr:not(:first)").html("");

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            handler.AddPara("UserName", encodeURIComponent(empName));
            var data = handler.DoMethodReturnString("FlowBBS_Check");


            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            if (data == "[]") {
                return;
            }
            //转化成json.
            data = JSON.parse(data);
            //增加处理.
            for (var i = 0; i < data.length; i++) {
                AddRow2(data[i]);

            }
        }

        function Submit() {

            if ($("#TB_Msg").val() == null || $("#TB_Msg").val() == "" || $("#TB_Msg").val().trim().length == 0) {
                alert("请填写评论内容!");
                return;
            }
            var i = 0;
            $(document).ready(function () {
                $("#Btn_Save").click(function () {
                    if (i == 1) {
                        time(document.getElementById("Btn_Save"));
                    }
                    i = i + 1;
                });

            });

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            handler.AddFormData();
            var data = handler.DoMethodReturnString("FlowBBS_Save");


            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            if (data == "[]") {
                return;
            }
            //转化成json.
            data = JSON.parse(data);
            AddRow(data[0]);
        }
        //清空评论
        function Clear() {
            $("#TB_Msg").val("");
            return;
        }
        //评论回复
        function Rel(empNo, pk, empName) {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();

            var data = handler.DoMethodReturnString("FlowBBSUserName");
            var url = "FlowBBSReplay.htm?RE=" + empNo + "&MyPK=" + pk + "&UserName=" + encodeURIComponent(empName) + "&WebUser=" + encodeURIComponent(data);
            WinOpen(url);

        }
        function AddRow(data) {
            var mypk = data.MyPK;
            var date = data.RDT;
            var empNo = data.EmpFrom;
            var empName = data.EmpFromT;
            var msg = data.Msg;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            handler.AddPara("UserName", empNo);
            var data = handler.DoMethodReturnString("FlowBBSDept");

            var leftInfo = "<img src='../../Img/Dot.png' border='1'  width='7px'/>&nbsp;" + empNo + "  <br/><br/>";
            //增加上icon.
            leftInfo += "<center ><img width='100' height='100'  src='../../../DataUser/UserIcon/" + empNo + "Biger.png' onerror=\"this.src='../../../DataUser/UserIcon/DefaultBiger.png'\" /> </center><br/><br/>";
            leftInfo += "发表人:&nbsp&nbsp" + empName + "<br>";
            leftInfo += "发表于:&nbsp&nbsp" + date + "<br>";
            leftInfo += "所属部门:&nbsp&nbsp" + data;
            var delLink = "<a href=\"javascript:Delete('" + mypk + "');\" ><img src='../../Img/Btn/Delete.gif' />删除</a>&nbsp&nbsp|&nbsp&nbsp<a href=\"javascript:Rel('" + empNo + "','" + mypk + "','" + empName + "');\"><img src='../../Img/Btn/Reply.gif' /> 回复</a>&nbsp&nbsp|&nbsp&nbsp<a href=\"javascript:Check('" + empName + "','" + fk_flow + "');\">只看该用户</a> ";
            var newRow = "<tr id='" + mypk + "'><th style='background-color: #dbe5f1' >" + leftInfo + "<br><br></th><th colspan='2'>" + msg + "<br/><br/><br/><br/><br/><br/><br/><hr style='height:1px;border:none;border-top:1px dashed blue;' />" + delLink + "</th></tr>";
            $("#Table1 tr:last").after(newRow);
            Count();
        }

        function AddRow2(data) {
            var mypk = data.MyPK;
            var date = data.RDT;
            var empNo = data.EmpFrom;
            var empName = data.EmpFromT;
            var msg = data.Msg;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            handler.AddPara("UserName", empNo);
            var data = handler.DoMethodReturnString("FlowBBSDept");

            var leftInfo = "<img src='../../Img/Dot.png' border='1'  width='7px'/>&nbsp;" + empNo + "<br/><br/>";
            //增加上icon.
            leftInfo += "<center ><img width='100' height='100'  src='../../../DataUser/UserIcon/" + empNo + "Biger.png' onerror=\"this.src='../../../DataUser/UserIcon/DefaultBiger.png'\" /> </center><br/><br/>";
            leftInfo += "发表人:&nbsp&nbsp" + empName + "<br>";
            leftInfo += "发表于:&nbsp&nbsp" + date + "<br>";
            leftInfo += "所属部门:&nbsp&nbsp" + data;
            var delLink = "<a href=\"javascript:Delete('" + mypk + "');\" ><img src='../../Img/Btn/Delete.gif' />删除</a>&nbsp&nbsp|&nbsp&nbsp<a href=\"javascript:Rel('" + empNo + "','" + mypk + "','" + empName + "');\"><img src='../../Img/Btn/Reply.gif' /> 回复</a>&nbsp&nbsp|&nbsp&nbsp<a href=\"javascript:InitPage();\">查看全部</a> ";
            var Row = "<tr id='" + mypk + "'><th style='background-color: #dbe5f1' >" + leftInfo + "<br><br></th><th class=BigDoc colspan='2'>" + msg + "<br/><br/><br/><br/><br/><br/><br/><hr style='height:1px;border:none;border-top:1px dashed blue;' /> " + delLink + "</th></tr>";
            $("#Table1 tr:last").after(Row);
            Count();
        }

        function goTop() {
            if (this.location.href.indexOf("#top") == -1) {
                this.location.href = this.location.href + "#top";
            }
            else {
                this.location.href = this.location.href;
            }
        }
    </script>
    <div align="center">
        <a name="top"></a>
        <table id="Table1" style="width: 100%;">
            <tr>
                <th style="width: 200px;">
                    资料
                </th>
                <th>
                    信息内容
                </th>
                <th style="text-align: right;">
                    评论总计条数:&nbsp<span style="color: red" id="TB_count" />
                </th>
            </tr>
        </table>
        <form id="cc" name="cc">
        <fieldset style="width: 98%;">
            <textarea rows="3" id="TB_Msg" name="TB_Msg" cols="60">
</textarea>
            <br />
            <input type="button" id="Btn_Save" name="Btn_Save" value="提交评论" onclick="Submit();" />
            <input type="button" id="Button1" name="Btn_Save" value="清空" onclick="Clear();" />
        </fieldset>
        </
        </form>
        <div id="Msg">
        </div>
    </div>
    <div class="side">
        <ul>
            <li style="border: none;"><a href="javascript:goTop();">
                <div class="sidebox">
                    <img src="Img/TOP.png">顶部</div>
            </a></li>
        </ul>
    </div>
</body>
</html>
